import './style.less'
import { useEffect, useState } from 'react';
import { checkAuth } from './helper'
import { useDispatch } from 'react-redux'
import { setEnvReady } from '@/store'
import { Outlet } from 'react-router-dom';
import TitleBar from './titlebar';

function App() {
    const dispatch = useDispatch();
    useEffect(() => {
        onCheckAuth()
    }, [])

    // 有没有权限进入应用
    const [auth, setAuth] = useState(false);
    const onCheckAuth = async () => {
        // const res = await checkAuth();
        // setAuth(res)
        // if (res) {
            // 初始化一些东西
            setAuth(true)
            import('@/utils/device-helper');
            dispatch(setEnvReady()); // 获取环境变量，设置为全局状态，虽然当前组件不用，但是全局会用到
        // }
    }
    return <>{auth && <div className="root">
        <TitleBar />
        <div className="content">
            <Outlet />
        </div>

    </div>}</>
}

export default App;